﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProdeFrontEnd.Clases;
using ProdeFrontEnd.ServiceReferenceProde;
using System.Data;

namespace ProdeFrontEnd.Pags
{
    public partial class PositionPoint : System.Web.UI.Page
    {
        private ServiceProde serviceProde;
         
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] == null) //Se tiene que salir
            {
                Response.Redirect("NewUser.aspx");
            }
            serviceProde = ServiceProde.getInstanceServiceProde();
            loadUserTournament();
        }

        private void loadUserTournament()
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.AddRange(new DataColumn[3] {
                                new DataColumn("name",typeof(string)),
                                new DataColumn("tournament",typeof(string)),
                                new DataColumn("points",typeof(string))});

            UserPoint[] userPoints = serviceProde.prodeClient.getUserpointsByTournamet(((User)Session["User"]));

            foreach (UserPoint userPoint in userPoints)
            {
                dataTable.Rows.Add(userPoint.userName, userPoint.tournamentName, userPoint.point);
            }

            GridView1.DataSource = dataTable;
            GridView1.DataBind();
        }
    }
}